package br.univas.vperiod.jowey.entities;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="week")
public class Week implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3748693310657215970L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private long idWeek;
	
	private String number;
	private int hours;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="idTime_report")
	private TimeReport timeReport;
	
	@OneToMany(mappedBy="week",targetEntity=PlayerReport.class,fetch=FetchType.LAZY)
	private Set<PlayerReport> playerReports;
	
	
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + hours;
		result = prime * result + (int) (idWeek ^ (idWeek >>> 32));
		result = prime * result + ((number == null) ? 0 : number.hashCode());
		result = prime * result
				+ ((playerReports == null) ? 0 : playerReports.hashCode());
		result = prime * result
				+ ((timeReport == null) ? 0 : timeReport.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Week other = (Week) obj;
		if (hours != other.hours)
			return false;
		if (idWeek != other.idWeek)
			return false;
		if (number == null) {
			if (other.number != null)
				return false;
		} else if (!number.equals(other.number))
			return false;
		if (playerReports == null) {
			if (other.playerReports != null)
				return false;
		} else if (!playerReports.equals(other.playerReports))
			return false;
		if (timeReport == null) {
			if (other.timeReport != null)
				return false;
		} else if (!timeReport.equals(other.timeReport))
			return false;
		return true;
	}

	public long getIdWeek() {
		return idWeek;
	}

	public void setIdWeek(long idWeek) {
		this.idWeek = idWeek;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public int getHours() {
		return hours;
	}

	public void setHours(int hours) {
		this.hours = hours;
	}

	public TimeReport getTimeReport() {
		return timeReport;
	}

	public void setTimeReport(TimeReport timeReport) {
		this.timeReport = timeReport;
	}

	public Set<PlayerReport> getPlayerReports() {
		return playerReports;
	}

	public void setPlayerReports(Set<PlayerReport> playerReports) {
		this.playerReports = playerReports;
	}
}
